package com.eascs.web.o2o.web.dao;

import java.util.List;

import javax.inject.Inject;

import org.springframework.stereotype.Repository;

import com.eascs.app.dao.JdbcSession;
import com.eascs.app.dao.PageResult;
import com.eascs.app.dao.SqlPageQuery;

@Repository
public class WebBaseDao {
	@Inject
	JdbcSession jdbcSession;
	@Inject
	JdbcSession jdbcSessionOracle;

	/**
	 * 实体集合
	 */
	public List<Object[]> findObjectsList(String sql){
		return jdbcSession.findObjectsList(sql);
	}
	/**
	 * 执行存储过程
	 */
	public void excuteProReport(String proSql){
		jdbcSession.execute(proSql);
	}
	
	/**
	 * 实体集合-带参数查询
	 */
	public List<Object[]> findObjectsList(String sql,Object... params){
		return jdbcSession.findObjectsList(sql,params);
	}
	
	/**
	 * 插入新数据
	 */
	public void isnertNewBusiness(String insertSql,Object... params){
		jdbcSession.execute(insertSql,params);
	}
	
	/**
	 * 删除数据
	 * @param deleteSql
	 */
	public void deleteNewBusiness(String deleteSql,String param){
		jdbcSession.execute(deleteSql,param);
	}
	
	public List<Object[]> findOracleObjectsList(String sql,Object... params){
		return jdbcSessionOracle.findObjectsList(sql,params);
	}
	
	public <T> PageResult<T> findDataWithPage(SqlPageQuery<T> sqlPageQuery) {
		return jdbcSession.findDataWithPage(sqlPageQuery);
	}
	
	public List<Object[]> findParamsForOracle(String sql,Object...params ){
		return this.jdbcSessionOracle.findObjectsList(sql, params);
	}
	
	public <T> List<T> findEntitys(String sql, Class<T> requiredType, Object... params) {

		return jdbcSession.findEntitys(sql, requiredType, params);
	}
}
